package cn.ainit.bj.comparsion;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ainit.bj.comparsion.entity.BjComparison;
import cn.ainit.common.ReturnObject;
import cn.ainit.sys.utils.UUID32;
@Controller
@RequestMapping("/comparsion")       //修改一个名字
public class ComparsionController {
	
	private ComparsionService comparsionService;
	@Resource  //参照ServiceImpl中一样
	public void setComparsionService(ComparsionService comparsionService) {
		this.comparsionService = comparsionService;
	}
	
	@RequestMapping("/saveOrUpdComp")
	@ResponseBody
	public ReturnObject saveOrUpdComp(BjComparison bjComparison,int panduan,HttpServletRequest request) throws Exception{
		ReturnObject returnObject = new ReturnObject();
		try {
			boolean flag = false;
			if (panduan == 0) {
				flag = comparsionService.saveComp(bjComparison);
				if (flag) {
					returnObject.setMsg("success");
					returnObject.setInfo(bjComparison.getCodeid());
				}else{
					returnObject.setMsg("fail");
				}
			}else{
				flag = comparsionService.updCompSave(bjComparison);
				if (flag) {
					returnObject.setMsg("upsuccess");
				}else {
					returnObject.setMsg("fail");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnObject;
	}
	
}
